﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace MyChart
{
    /// <summary>
    /// 2D横向柱状图
    /// </summary>
    public class Bar2D : Coordinate
    {
        #region 字段

        private bool _glassStyle = true;

        #endregion

        #region 属性

        /// <summary>
        /// 获取或设置一个值，表示控件是否启用玻璃样式
        /// </summary>
        public bool GlassStyle
        {
            get { return _glassStyle; }
            set { _glassStyle = value; }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 获取控件的 FusionChart 完整Xml配置字符串
        /// </summary>
        /// <returns>完整的Xml配置字符串</returns>
        public override string GetRenderHtml()
        {
            StringBuilder xml = new StringBuilder();

            xml.Append(@"<chart useRoundEdges='" + (_glassStyle ? 1 : 0) + "'" + (FormatNumber ? " formatNumber='1'" : "") + " caption='" + Caption + "' subcaption='" + SubCaption + "' animation='" + (Animation ? 1 : 0) + "' isSliced='" + (IsSliced ? 1 : 0) + "'"
                + " palette='" + (int)Theme + "' showLabels='" + (ShowLabels ? 1 : 0) + "' showValues='" + (ShowValues ? 1 : 0) + "'"
                + " numberPrefix='" + NumberPrefix + "' numberSuffix='" + NumberSuffix + "' decimals='" + Decimals + "' decimalPrecision='" + Decimals + "'" + (BgColor.ToArgb() != 0 ? " bgColor='" + BgColor.ToArgb().ToString("X").Remove(0, 2) + "'" : "")
                + " showBorder='" + (ShowBorder ? 1 : 0) + "' baseFont='" + BaseFont.Name + "' baseFontSize='" + BaseFont.Size + "'"
                + (ForeColor.ToArgb() != 0 ? " baseFontColor='" + ForeColor.ToArgb().ToString("X").Remove(0, 2) + "'" : "")
                + " xAxisName='" + XAxisName + "' yAxisName='" + YAxisName + "' yAxisMinValue='" + YAxisMinValue + "'" + (YAxisMaxValue == YAxisMinValue ? "" : " yAxisMaxValue='" + YAxisMaxValue + "'")
                + " numDivLines='" + HorizontalLineCount + "' numVDivLines='" + VerticalLineCount + "' anchorRadius='" + AnchorRadius + "'"
                + (RotateLabel ? " labelDisplay='rotate' slantLabels='1'" : "") + " chartTopMargin='" + MarginTop + "' chartBottomMargin='" + MarginBottom + "'"
                + " chartLeftMargin='" + MarginLeft + "' chartRightMargin='" + MarginRight + "'"
                + (XAxisLabelStep > 0 ? " labelStep='" + XAxisLabelStep + "'" : "") + " formatNumberScale='" + (FormatNumberScale ? 1 : 0) + "'>");

            xml.Append(GetItemManagerXmlString());
            xml.Append(GetTargetLinesXmlString());
            xml.Append("</chart>");

            return xml.ToString();
        }

        #endregion
    }
}
